package com.example.wxback;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@SpringBootApplication
@RestController
@MapperScan("com.example.wxback.dao")
@EnableScheduling
public class WxbackApplication extends SpringBootServletInitializer {

    @Autowired
    IUserService userService;

    public static void main(String[] args) {
        SpringApplication.run(WxbackApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(WxbackApplication.class);
    }

    @GetMapping("/hello")
    public String hello() {
        return "Hello WxbackApplication";
    }

    @GetMapping("/users")
    public List<UserModel> users() {
        return userService.userList();
    }
}